package com.c5p1ng.core.generator;

import com.c5p1ng.core.generator.base.GenericGenerator;
import com.c5p1ng.core.util.ChineseCharUtils;
import com.c5p1ng.core.util.RandomUtil;

/**
 * 中文地址生成器
 *
 * @author c5p1ng
 */
public class ChineseAddressGenerator extends GenericGenerator {
    private static GenericGenerator instance = new ChineseAddressGenerator();

    private ChineseAddressGenerator() {
    }

    public static GenericGenerator getInstance() {
        return instance;
    }

    public String generate() {
        StringBuilder result = new StringBuilder(genProvinceAndCity());
        result.append(ChineseCharUtils.genRandomLengthChineseChars(2, 3) + "路");
        result.append(RandomUtil.randomInt(1, 8000) + "号");
        result.append(ChineseCharUtils.genRandomLengthChineseChars(2, 3) + "小区");
        result.append(RandomUtil.randomInt(1, 20) + "单元");
        result.append(RandomUtil.randomInt(101, 2500) + "室");
        return result.toString();
    }

    private static String genProvinceAndCity() {
        return (String) ChineseAreaList.provinceCityList.get(RandomUtil.randomInt(0, ChineseAreaList.provinceCityList.size()));
    }
}
